package com.teaphy.coroutinecrawler.flow

import kotlinx.coroutines.delay
import kotlinx.coroutines.flow.*
import kotlinx.coroutines.*
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {

    val flow: Flow<String> = channelFlow {
        val data = listOf<String>("A", "B", "C")
        data.forEach {
            delay(1000)
            println("发送数据：$it")
            send(it)

        }
    }

    flow.collect {
        delay(1000)
        println("接收数据: $it")
    }

    print("Done")
}


